# @Author   : tan90
# @Time     : 2025/3/18 10:32
from tkinter import *
from tkinter import messagebox


def hit_me():
    print("hello, world")
    messagebox.showinfo("提示框", "why hit me?")


class Application(Frame):
    def __init__(self, master=None):
        # 方式一
        super().__init__(master)
        # 方式二
        # Frame.__init__(self, master)
        self.btn1 = None
        self.btn2 = None
        self.pack()
        self.createWidgets()

    def createWidgets(self):
        self.btn1 = Button(self, text='hit me', command=hit_me)
        self.btn1.pack()

        self.btn2 = Button(self, text='退出', command=self.master.destroy)
        self.btn2.pack()

if __name__ == '__main__':
    app = Tk()
    app.geometry("400x300+100+100")
    app.title("我的第一个GUI程序")
    Application(master=app)
    app.mainloop()
